Prerequisites
- A metered feature created in Flexprice
- Your API key from the Admin Dashboard
- The Event Name from your feature configuration
API Endpoints
Single Event
Bulk Events
Authentication
Include your API key in the request header:Event Payload Structure
Required Fields
Field | Type | Description | Example |
---|---|---|---|
event_name | string | Must exactly match your feature’s Event Name | "model.usage" |
external_customer_id | string | Your identifier for the customer | "cust_123" |
Conditional Fields
Field | Type | When Required | Description |
---|---|---|---|
properties | object | For Sum, Max, Latest, Unique Count | Contains the values to aggregate |
properties.<field> | number/string | When aggregation field is set | The exact field name from your feature configuration |
Optional Fields
Field | Type | Description | Example |
---|---|---|---|
event_id | string | Your unique identifier for the event | "evt_123" |
timestamp | string | ISO 8601 UTC timestamp | "2025-08-22T07:05:49.441Z" |
source | string | Origin of the event | "api" , "worker" |
Single Event Examples
Basic Event (Count Aggregation)
If your feature uses Count aggregation, you only need the required fields:Event with Properties (Sum Aggregation)
If your feature uses Sum aggregation with fieldcredits
:
Complete Event Example
cURL Examples
Single Event

Response

Bulk Events
Transmit multiple events in a single request for better performance:Language Examples
JavaScript (Node.js)
Python
Go
PHP
Data Types and Best Practices
Property Values
-
Numbers: Use for Sum, Max aggregations
-
Strings: Use for Unique Count, Latest aggregations
Timestamps
- Use ISO 8601 format in UTC
- Example:
"2025-08-22T07:05:49.441Z"
- If omitted, server time is used
Event IDs
- Optional but recommended for traceability
- Should be unique within your system
- Helps with debugging and idempotency
Common Patterns
API Usage Tracking
Storage Usage
User Activity
Error Handling
HTTP Status Codes
- 202 Accepted: Event accepted for processing
- 400 Bad Request: Invalid payload or missing required fields
- 401 Unauthorized: Invalid or missing API key
- 429 Too Many Requests: Rate limit exceeded
Common Errors
Missing required fieldRate Limits
- Single events: 1000 requests per minute
- Bulk events: 100 requests per minute (up to 1000 events per request)
- Response: 429 status code when exceeded
Best Practices
1. Validate Your Configuration
Before transmitting production events:- Verify Event Name matches your feature exactly
- Confirm Aggregation Field exists in your events
- Test with a small number of events first
2. Handle Failures Gracefully
3. Use Bulk Events for High Volume
When transmitting many events, use the bulk endpoint:4. Include Relevant Metadata
Add useful properties to your events for debugging:Related Documentation
- API Reference — Complete API documentation
- Validating Events — Check that events are being processed correctly
- Troubleshooting — Fix common issues
Next Steps
After sending events, you should:- Validate Events - Verify that events are being processed correctly
- Connect to Billing - Set up pricing and subscriptions
Troubleshooting
”Event not found” error
- Check that Event Name matches your feature exactly
- Verify the feature exists and is active
”Customer not found” error
- Ensure the customer exists in Flexprice
- Check that
external_customer_id
matches exactly
”Missing required field” error
- Verify all required fields are present
- Check field names match exactly (case-sensitive)
Events not appearing in dashboard
- Check the Event Debugger for processing status
- Verify Event Name and Aggregation Field configuration
- Ensure customer has an active subscription with the feature